xenstore transaction retry loops in our device drivers.
Otherwise things get very smelly if a transaction fails and
is retried.
Signed-off-by: Keir Fraser <keir@xensource.com>
return;
}
+ /* Map the shared frame, irq etc. */
+ err = blkif_map(be->blkif, ring_ref, evtchn);
+ if (err) {
+ xenbus_dev_error(be->dev, err, "mapping ring-ref %lu port %u",
+ ring_ref, evtchn);
+ return;
+ }
+ /* XXX From here on should 'blkif_unmap' on error. */
+
again:
/* Supply the information about the device the frontend needs */
err = xenbus_transaction_start();
goto abort;
}
- /* Map the shared frame, irq etc. */
- err = blkif_map(be->blkif, ring_ref, evtchn);
- if (err) {
- xenbus_dev_error(be->dev, err, "mapping ring-ref %lu port %u",
- ring_ref, evtchn);
- goto abort;
- }
-
err = xenbus_transaction_end(0);
if (err == -EAGAIN)
goto again;
goto abort_transaction;
}
- info->backend = backend;
- backend = NULL;
-
- info->watch.node = info->backend;
- info->watch.callback = watch_for_status;
- err = register_xenbus_watch(&info->watch);
- if (err) {
- message = "registering watch on backend";
- goto abort_transaction;
- }
-
err = xenbus_transaction_end(0);
if (err) {
if (err == -EAGAIN)
goto destroy_blkring;
}
- out:
- if (backend)
- kfree(backend);
- return err;
+ info->watch.node = backend;
+ info->watch.callback = watch_for_status;
+ err = register_xenbus_watch(&info->watch);
+ if (err) {
+ message = "registering watch on backend";
+ goto destroy_blkring;
+ }
+
+ info->backend = backend;
+
+ return 0;
abort_transaction:
xenbus_transaction_end(1);
xenbus_dev_error(dev, err, "%s", message);
destroy_blkring:
blkif_free(info);
- goto out;
+ out:
+ if (backend)
+ kfree(backend);
+ return err;
}
/* Setup supplies the backend dir, virtual device.
goto abort_transaction;
}
- info->backend = backend;
- backend = NULL;
-
- info->watch.node = info->backend;
- info->watch.callback = watch_for_status;
- err = register_xenbus_watch(&info->watch);
- if (err) {
- message = "registering watch on backend";
- goto abort_transaction;
- }
-
err = xenbus_transaction_end(0);
if (err) {
if (err == -EAGAIN)
goto destroy_ring;
}
+ info->watch.node = backend;
+ info->watch.callback = watch_for_status;
+ err = register_xenbus_watch(&info->watch);
+ if (err) {
+ message = "registering watch on backend";
+ goto destroy_ring;
+ }
+
+ info->backend = backend;
+
netif_state = NETIF_STATE_CONNECTED;
- out:
- if (backend)
- kfree(backend);
- return err;
+ return 0;
abort_transaction:
xenbus_transaction_end(1);
xenbus_dev_error(dev, err, "%s", message);
destroy_ring:
shutdown_device(info);
- goto out;
+ out:
+ if (backend)
+ kfree(backend);
+ return err;
}
/* Setup supplies the backend dir, virtual device.
return;
}
-
- /*
- * Tell the front-end that we are ready to go -
- * unless something bad happens
- */
-again:
- err = xenbus_transaction_start();
- if (err) {
- xenbus_dev_error(be->dev, err, "starting transaction");
- return;
- }
-
- err = xenbus_printf(be->dev->nodename,
- "ready", "%lu", ready);
- if (err) {
- xenbus_dev_error(be->dev, err, "writing 'ready'");
- goto abort;
- }
-
err = tpmif_map(be->tpmif, ringref, evtchn);
if (err) {
xenbus_dev_error(be->dev, err,
"mapping shared-frame %lu port %u",
ringref, evtchn);
- goto abort;
+ return;
}
err = tpmif_vtpm_open(be->tpmif,
* Should close down this device and notify FE
* about closure.
*/
+ return;
+ }
+
+ /*
+ * Tell the front-end that we are ready to go -
+ * unless something bad happens
+ */
+again:
+ err = xenbus_transaction_start();
+ if (err) {
+ xenbus_dev_error(be->dev, err, "starting transaction");
+ return;
+ }
+
+ err = xenbus_printf(be->dev->nodename,
+ "ready", "%lu", ready);
+ if (err) {
+ xenbus_dev_error(be->dev, err, "writing 'ready'");
goto abort;
}
goto abort_transaction;
}
- info->backend = backend;
- backend = NULL;
-
- info->watch.node = info->backend;
- info->watch.callback = watch_for_status;
- err = register_xenbus_watch(&info->watch);
- if (err) {
- message = "registering watch on backend";
- goto abort_transaction;
- }
-
err = xenbus_transaction_end(0);
if (err == -EAGAIN)
goto again;
goto destroy_tpmring;
}
-out:
- if (backend)
- kfree(backend);
- return err;
+ info->watch.node = backend;
+ info->watch.callback = watch_for_status;
+ err = register_xenbus_watch(&info->watch);
+ if (err) {
+ message = "registering watch on backend";
+ goto destroy_tpmring;
+ }
+
+ info->backend = backend;
+
+ return 0;
abort_transaction:
xenbus_transaction_end(1);
xenbus_dev_error(dev, err, "%s", message);
destroy_tpmring:
destroy_tpmring(info, &my_private);
- goto out;
+out:
+ if (backend)
+ kfree(backend);
+ return err;
}